package indi.zjh.dp.verify;

import indi.zjh.dp.error.InvalidDataException;

public class Check {
	protected String data = "";
	protected String desc = "";
	
	public static Check data(String input)
	{
		Check c = new Check();
		c.data = input;
		return c;
	}
	
	public Check desc(String desc)
	{
		this.desc = desc;
		return this;
	}
	
	public Check rule(Rule r) throws InvalidDataException
	{
		if(!r.test(this.data))
			throw new InvalidDataException(this.desc+":"+this.data+":"+r.desc());
		return this;
	}

}
